package entity

import (
	"gluenet/modules/manager/server/domain/po"
	"gluenet/modules/manager/server/domain/vo"
	"gluenet/modules/manager/server/infra"
)

type RegisterOrder struct {
	infra.Entity
	po.RegisterOrder
}

func (r *RegisterOrder) Identity() string {
	return r.RegisterOrder.OrderID
}

func (r *RegisterOrder) NewFormInstance(instance *Instance) {
	r.RegisterOrder.OrderID = infra.NewID()
	r.RegisterOrder.ObjectIdentity = instance.Identity()
	r.RegisterOrder.ObjectKind = instance.Kind
	r.RegisterOrder.ObjectPlatform = instance.Platform
	r.RegisterOrder.ObjectDetail = instance
}

func (r *RegisterOrder) NewFormAgent(agent *vo.AgentRegisterReq) {
	r.RegisterOrder.OrderID = infra.NewID()
	r.RegisterOrder.ObjectIdentity = ""
	r.RegisterOrder.ObjectKind = KindAgent
	r.RegisterOrder.ObjectPlatform = agent.Platform
	r.RegisterOrder.ObjectDetail = agent
}
